package com.ruoyi.paas.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.paas.domain.XspUserSiginLog;
import com.ruoyi.paas.service.IXspUserSiginLogService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 用户签到记录Controller
 * 
 * @author zhiminhu
 * @date 2021-04-26
 */
@Controller
@RequestMapping("/paas/signLog")
public class XspUserSiginLogController extends BaseController
{
    private String prefix = "paas/signLog";

    @Autowired
    private IXspUserSiginLogService xspUserSiginLogService;

    @RequiresPermissions("paas:signLog:view")
    @GetMapping()
    public String signLog()
    {
        return prefix + "/signLog";
    }

    /**
     * 查询用户签到记录列表
     */
    @RequiresPermissions("paas:signLog:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(XspUserSiginLog xspUserSiginLog)
    {
        startPage();
        List<XspUserSiginLog> list = xspUserSiginLogService.selectXspUserSiginLogList(xspUserSiginLog);
        return getDataTable(list);
    }

    /**
     * 导出用户签到记录列表
     */
    @RequiresPermissions("paas:signLog:export")
    @Log(title = "用户签到记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(XspUserSiginLog xspUserSiginLog)
    {
        List<XspUserSiginLog> list = xspUserSiginLogService.selectXspUserSiginLogList(xspUserSiginLog);
        ExcelUtil<XspUserSiginLog> util = new ExcelUtil<XspUserSiginLog>(XspUserSiginLog.class);
        return util.exportExcel(list, "用户签到记录数据");
    }

    /**
     * 新增用户签到记录
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存用户签到记录
     */
    @RequiresPermissions("paas:signLog:add")
    @Log(title = "用户签到记录", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(XspUserSiginLog xspUserSiginLog)
    {
        return toAjax(xspUserSiginLogService.insertXspUserSiginLog(xspUserSiginLog));
    }

    /**
     * 修改用户签到记录
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        XspUserSiginLog xspUserSiginLog = xspUserSiginLogService.selectXspUserSiginLogById(id);
        mmap.put("xspUserSiginLog", xspUserSiginLog);
        return prefix + "/edit";
    }

    /**
     * 修改保存用户签到记录
     */
    @RequiresPermissions("paas:signLog:edit")
    @Log(title = "用户签到记录", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(XspUserSiginLog xspUserSiginLog)
    {
        return toAjax(xspUserSiginLogService.updateXspUserSiginLog(xspUserSiginLog));
    }

    /**
     * 删除用户签到记录
     */
    @RequiresPermissions("paas:signLog:remove")
    @Log(title = "用户签到记录", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(xspUserSiginLogService.deleteXspUserSiginLogByIds(ids));
    }
}
